﻿<%@ WebHandler Language="C#" Class="SIPO.Web.AjaxHandler.Loaddata.getregistrationemisiontype" %>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using SIPO.Library.DataAccess.Administration.Catalog;
using SIPO.Library.DomainObject.Administration.Catalog;
using SIPO.Library.Enum;
using SIPO.Web.Support;
using Newtonsoft.Json.Linq;
using System.Text;

namespace SIPO.Web.AjaxHandler.Loaddata
{

    public class getregistrationemisiontype : SIPO.Web.BaseHandler
    {
        recRegistrationEmisionTypeRepo recRegistrationEmisionTypeDal = new recRegistrationEmisionTypeRepo(ConfigurationManager.ConnectionStrings["SIPOConn"].ConnectionString);
        public override void ProcessRequest(HttpContext context)
        {
            base.ProcessRequest(context);
            int registrationEmisionTypeId = 0;
            if (context.Request.Params["registrationEmisionTypeId"] != null)
            {
                decimal isImision = 0;
                registrationEmisionTypeId = Convert.ToInt32(context.Request.Params["registrationEmisionTypeId"]);
                recRegistrationEmisionType registrationEmisionTypes = recRegistrationEmisionTypeDal.GetById((short)registrationEmisionTypeId);
                if (registrationEmisionTypes != null)
                    isImision = registrationEmisionTypes.IsEmision == true ? 1 : 0;
                StringBuilder sbProject = new StringBuilder();
                sbProject.Append("{");
                sbProject.AppendFormat("  {0}IsEmision{0}:{0}{1}{0}", "\"", isImision);
                sbProject.Append("}");

                context.Response.Write(sbProject.ToString());
            }
            else
            {
                List<recRegistrationEmisionType> registrationEmisionTypes = recRegistrationEmisionTypeDal.GetList();
                var result = registrationEmisionTypes;
                context.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(result));
            }
        }
        public override bool IsReusable
        {
            get
            {
                return false;
            }
        }

    }
}